package com.xxzx.publicprevention.service.impl;

import com.xxzx.publicprevention.pojo.RecordfilerelationDO;
import com.xxzx.publicprevention.mapper.RecordfilerelationMapper;
import com.xxzx.publicprevention.service.RecordfilerelationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 地质灾害文件关系表  服务实现类
 * </p>
 *
 * @author liyu
 * @since 2020-11-04
 */
@Service
public class RecordfilerelationServiceImpl extends ServiceImpl<RecordfilerelationMapper, RecordfilerelationDO> implements RecordfilerelationService {
    @Autowired
    private RecordfilerelationMapper recordfilerelationMapper;

    @Override
    public void saveRelations(RecordfilerelationDO rela) {
        recordfilerelationMapper.addRelations(rela);

    }

    @Override
    public void deleteRelationsByRecordId(Integer id) {
        List<RecordfilerelationDO> lists = recordfilerelationMapper.getRelationsByRecordId(id);

        for (RecordfilerelationDO c : lists) {
            recordfilerelationMapper.deleteRelaById(c.getId());
        }

    }

    @Override
    public List<RecordfilerelationDO> getRelationsByRecordId(int id) {


        return recordfilerelationMapper.getRelationsByRecordId(id);
    }
}
